package cn.sc.allinpay.allfavour.business.common.data;

import android.os.Parcel;
import android.os.Parcelable;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;

/**
 * 该交易对象只用于存储在数据库
 * description：交易记录
 * author：pany
 * on 2018/8/16 15:02
 */
public class TransRecord implements Parcelable {

    @DatabaseField(generatedId = true)
    public int id;

    @DatabaseField(columnName = "TRANSNO", unique = true)
    public String transNo;//流水号

    @DatabaseField(columnName = "ORDERID")
    public String orderId;//订单号,营销前置订单

    @DatabaseField(columnName = "TRANSAMT")
    public String transAmt;//交易金额，即订单总金额

    @DatabaseField(columnName = "PAIDAMT")
    public String paidAmt;//支付金额，即使用POS应用支付金额(包括现金支付和刷卡扫码支付的金额)

    @DatabaseField(columnName = "DISRIGHTSAMT")
    public String disRightsAmt;//会员权益优惠金额

    @DatabaseField(columnName = "DISCOUPONAMT")
    public String disCouponAmt;//卡券使用金额

    @DatabaseField(columnName = "DISEWALLETAMT")
    public String disEWalletAmt;//电子钱包使用金额

    @DatabaseField(columnName = "TRANSDATE")
    public String transDate;//交易日期

    @DatabaseField(columnName = "TRANSTIME")
    public String transTime;//交易时间

    @DatabaseField(columnName = "STATE")
    private int state = 0;//支付状态  0：无支付状态 1:支付中 2:支付成功(全单支付完成) 3:撤销中(尚有其他子订单尚未撤销成功的) 4:撤销成功(全单撤销完成)

    @DatabaseField(columnName = "SELLSTATE")
    private int sellState = 0;//抵扣状态  0:无抵扣(普通交易) 1:部分抵扣成功  2:抵扣撤销 3:全额抵扣成功 4：全额抵扣撤销

    @DatabaseField(columnName = "desc")
    private String desc;//扩展字段，暂时未用

    /************************订单详情**************************/
    @DatabaseField(columnName = "ORDERDATA", canBeNull = true, dataType = DataType.LONG_STRING)
    public String orderData;//就是PayOrderData对象的json

    /************************pos支付详情**************************/
    @DatabaseField(columnName = "POSDATA", canBeNull = true, dataType = DataType.LONG_STRING)
    public String posData;//就是PosData对象的json

    public TransRecord() {

    }


    protected TransRecord(Parcel in) {
        id = in.readInt();
        transNo = in.readString();
        orderId = in.readString();
        transAmt = in.readString();
        paidAmt = in.readString();
        disRightsAmt = in.readString();
        disCouponAmt = in.readString();
        disEWalletAmt = in.readString();
        transDate = in.readString();
        transTime = in.readString();
        state = in.readInt();
        sellState = in.readInt();
        desc = in.readString();
        orderData = in.readString();
        posData = in.readString();
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTransNo() {
        return transNo;
    }

    public void setTransNo(String transNo) {
        this.transNo = transNo;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getTransAmt() {
        return transAmt;
    }

    public void setTransAmt(String transAmt) {
        this.transAmt = transAmt;
    }

    public String getPaidAmt() {
        return paidAmt;
    }

    public void setPaidAmt(String paidAmt) {
        this.paidAmt = paidAmt;
    }

    public String getDisRightsAmt() {
        return disRightsAmt;
    }

    public void setDisRightsAmt(String disRightsAmt) {
        this.disRightsAmt = disRightsAmt;
    }

    public String getDisCouponAmt() {
        return disCouponAmt;
    }

    public void setDisCouponAmt(String disCouponAmt) {
        this.disCouponAmt = disCouponAmt;
    }

    public String getDisEWalletAmt() {
        return disEWalletAmt;
    }

    public void setDisEWalletAmt(String disEWalletAmt) {
        this.disEWalletAmt = disEWalletAmt;
    }

    public String getTransDate() {
        return transDate;
    }

    public void setTransDate(String transDate) {
        this.transDate = transDate;
    }

    public String getTransTime() {
        return transTime;
    }

    public void setTransTime(String transTime) {
        this.transTime = transTime;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public int getSellState() {
        return sellState;
    }

    public void setSellState(int sellState) {
        this.sellState = sellState;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getOrderData() {
        return orderData;
    }

    public void setOrderData(String orderData) {
        this.orderData = orderData;
    }

    public String getPosData() {
        return posData;
    }

    public void setPosData(String posData) {
        this.posData = posData;
    }

    public static final Creator<TransRecord> CREATOR = new Creator<TransRecord>() {
        @Override
        public TransRecord createFromParcel(Parcel in) {
            return new TransRecord(in);
        }

        @Override
        public TransRecord[] newArray(int size) {
            return new TransRecord[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeInt(id);
        parcel.writeString(transNo);
        parcel.writeString(orderId);
        parcel.writeString(transAmt);
        parcel.writeString(paidAmt);
        parcel.writeString(disRightsAmt);
        parcel.writeString(disCouponAmt);
        parcel.writeString(disEWalletAmt);
        parcel.writeString(transDate);
        parcel.writeString(transTime);
        parcel.writeInt(state);
        parcel.writeInt(sellState);
        parcel.writeString(desc);
        parcel.writeString(orderData);
        parcel.writeString(posData);
    }
}
